<script setup lang="ts">
import { getSystemInfo, showModal } from '@/utils'

onLaunch(async (e) => {
  console.log('App Launch')
})
onShow(async (e) => {
  await getSystemInfo()
  const updateManager = uni.getUpdateManager()

  updateManager.onCheckForUpdate((res) => {
    // 请求完新版本信息的回调
    console.log(res.hasUpdate, 'onCheckForUpdate hasUpdate')
  })

  updateManager.onUpdateReady(() => {
    showModal({
      title: '更新提示',
      content: '新版本已经准备好，是否重启应用？',
      success(res) {
        if (res.confirm) {
          // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
          updateManager.applyUpdate()
        }
      },
    })
  })
  updateManager.onUpdateFailed(() => {
    // 新版本下载失败
    showModal({ title: '更新提示', content: '新版本下载失败', showCancel: false })
  })
  console.log('App Show')
})
onHide(() => {
})
onUnload(() => {
})
</script>

<style lang="scss">
page {
  background-color: #f6f7fb;
}

.font-pf {
  font-family: PingFangSC-Semibold, PingFang SC;
}

.cancel_scrollbar ::-webkit-scrollbar {
  display: none;
  width: 0 !important;
  height: 0 !important;
  -webkit-appearance: none;
  background: transparent;
}

.line-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
